# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2022-2025, The OpenROAD Authors
load("//test:regression.bzl", "regression_test")

# From CMakeLists.txt or_integration_tests(TESTS
COMPULSORY_TESTS = [
    "aes_asap7_vdd",
    "aes_test_bterms",
    "aes_test_multiple_bterms",
    "aes_test_vdd",
    "aes_test_vss",
    "check_power_grid",
    "check_power_grid_disconnected",
    "check_power_grid_disconnected_macro",
    "check_power_grid_floorplanning",
    "check_power_grid_macros",
    "check_power_grid_ok_disconnected",
    "check_power_grid_require_bterms_fail",
    "check_power_grid_require_bterms_pass",
    "corners",
    "corners_assign_power",
    "gcd_all_vss",
    "gcd_em_test_vdd",
    "gcd_no_vsrc",
    "gcd_no_vsrc_reuse",
    "gcd_sky130_vdd",
    "gcd_test_assign_power",
    "gcd_test_vdd",
    "gcd_vss_no_vsrc",
    "gcd_write_sp_test_vdd",
    "insert_decap1",
    "insert_decap2",
    "insert_decap_with_padding1",
    "missing_resistance",
    "pad_connected_by_abutment",
    "switch_top_grid",
    "top_grid_settings",
    "zerosoc_pads",
    "zerosoc_pads_check_only",
    "zerosoc_pads_check_only_disconnected",
]

# Disabled in CMakeLists.txt
MANUAL_TESTS = [
    "psm_man_tcl_check",
    "psm_readme_msgs_check",
]

ALL_TESTS = COMPULSORY_TESTS + MANUAL_TESTS

filegroup(
    name = "regression_resources",
    # Dependencies could be specified more narrowly per test case,
    # but at least it is not a glob of everything and there are
    # per test glob patterns below.
    srcs = [
        "Nangate45/Nangate45.lef",
        "Nangate45/Nangate45.pdn.tcl",
        "Nangate45/Nangate45.rc",
        "Nangate45/Nangate45.rcx_rules",
        "Nangate45/Nangate45.tracks",
        "Nangate45/Nangate45.vars",
        "Nangate45/Nangate45_fast.lib",
        "Nangate45/Nangate45_lvt.lef",
        "Nangate45/Nangate45_lvt.lib",
        "Nangate45/Nangate45_slow.lib",
        "Nangate45/Nangate45_stdcell.lef",
        "Nangate45/Nangate45_tech.lef",
        "Nangate45/Nangate45_typ.lib",
        "Nangate45/fake_macros.lef",
        "Nangate45/fake_macros.lib",
        "Nangate45/fakeram45.cfg",
        "Nangate45/fakeram45_1024x32.lef",
        "Nangate45/fakeram45_1024x32.lib",
        "Nangate45/fakeram45_256x16.lef",
        "Nangate45/fakeram45_256x16.lib",
        "Nangate45/fakeram45_512x64.lef",
        "Nangate45/fakeram45_512x64.lib",
        "Nangate45/fakeram45_64x32.lef",
        "Nangate45/fakeram45_64x32.lib",
        "Nangate45/fakeram45_64x7.lef",
        "Nangate45/fakeram45_64x7.lib",
        "Nangate45/fakeram45_64x96.lef",
        "Nangate45/fakeram45_64x96.lib",
        "Nangate45/work_around_yosys/cells.v",
        "Nangate45_data/Nangate45_corners.rc",
        "Nangate45_data/aes.def",
        "Nangate45_data/aes.sdc",
        "Nangate45_data/aes_bterms.def",
        "Nangate45_data/aes_multi_bterms.def",
        "Nangate45_data/check_power_grid_disconnected.def",
        "Nangate45_data/check_power_grid_ok_disconnected.def",
        "Nangate45_data/fakeram45_64x32.lef",
        "Nangate45_data/gcd.def",
        "Nangate45_data/gcd.sdc",
        "Nangate45_data/gcd_floorplanning.def",
        "Vsrc_aes_vdd.loc",
        "Vsrc_aes_vss.loc",
        "Vsrc_gcd_vdd.loc",
        "Vsrc_gcd_vss.loc",
        "asap7/asap7_tech_1x_201209.lef",
        "asap7/asap7sc7p5t_28_R_1x_220121a.lef",
        "asap7/asap7sc7p5t_AO_RVT_FF_nldm_211120.lib.gz",
        "asap7/asap7sc7p5t_INVBUF_RVT_FF_nldm_220122.lib.gz",
        "asap7/asap7sc7p5t_OA_RVT_FF_nldm_211120.lib.gz",
        "asap7/asap7sc7p5t_SEQ_RVT_FF_nldm_220123.lib",
        "asap7/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz",
        "asap7/setRC.tcl",
        "asap7_data/aes_place.def",
        "asap7_data/aes_place.sdc",
        "asap7_data/asap7.lib",
        "asap7_data/fakeram7_256x32.lef",
        "asap7_data/riscv.def",
        "gcd_all_vss-em.rptok",
        "gcd_all_vss-spice.spok",
        "gcd_all_vss-voltage.rptok",
        "gcd_em_test_vdd-em.rptok",
        "gcd_test_vdd-voltage.rptok",
        "helpers.tcl",
        "ihp-sg13g2_data/IOLib.lef",
        "ihp-sg13g2_data/IOLib_dummy.lib",
        "ihp-sg13g2_data/setRC.tcl",
        "ihp-sg13g2_data/sg13g2_stdcell.lef",
        "ihp-sg13g2_data/sg13g2_stdcell_typ_1p20V_25C.lib",
        "ihp-sg13g2_data/sg13g2_tech.lef",
        "sky130hd/sky130_fd_sc_hd__ff_n40C_1v95.lib",
        "sky130hd/sky130_fd_sc_hd__ss_n40C_1v40.lib",
        "sky130hd/sky130_fd_sc_hd__tt_025C_1v80.lib",
        "sky130hd/sky130_fd_sc_hd_merged.lef",
        "sky130hd/sky130hd.pdn.tcl",
        "sky130hd/sky130hd.rc",
        "sky130hd/sky130hd.rcx_rules",
        "sky130hd/sky130hd.tlef",
        "sky130hd/sky130hd.tracks",
        "sky130hd/sky130hd.vars",
        "sky130hd/sky130hd_multi_patterned.tlef",
        "sky130hd/sky130hd_std_cell.lef",
        "sky130hd/sky130hd_std_cell_vt.lef",
        "sky130hd/sky130hd_tt.lib",
        "sky130hd/sky130hd_vt.tlef",
        "sky130hd/work_around_yosys/formal_pdk.v",
        "sky130hd_data/gcd_sky130hd_floorplan.def",
        "sky130hd_data/gcd_sky130hd_floorplan.sdc",
        "sky130hd_data/insert_decap_gcd.def",
        "sky130hd_data/io/sky130_dummy_io.lef",
        "sky130hd_data/io/sky130_dummy_io.lib",
        "sky130hd_data/ram/sky130_sram_2kbyte_1rw1r_32x512_8.lef",
        "sky130hd_data/ram/sky130_sram_2kbyte_1rw1r_32x512_8_TT_1p8V_25C.lib",
        "sky130hd_data/zerosoc_pads.def",
        "sky130hd_data/zerosoc_pads.sdc",
    ],
)

[
    filegroup(
        name = test_name + "_resources",
        srcs = [":regression_resources"] + glob(
            [
                test_name + ".*",
            ],
        ),
    )
    for test_name in ALL_TESTS
]

[
    regression_test(
        name = test_name,
        data = [":" + test_name + "_resources"],
        tags = [] if test_name in COMPULSORY_TESTS else ["manual"],
        visibility = ["//visibility:public"],
    )
    for test_name in ALL_TESTS
]
